package netWork;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25397
 * Date: 2022-04-16
 * Time: 17:08
 */
public class UdpDictServer extends UdpEchoServer{
    private HashMap<String,String> dict=new HashMap<>();

    public UdpDictServer(int port) throws SocketException {
        super(port);
        //这里只简单构造几个词，你如果需要更多，你自己添加即可
        dict.put("cat","猫");
        dict.put("dog","狗");
        dict.put("pig","猪");
    }

    @Override
    public String process(String request){
        return dict.getOrDefault(request,"该词无法被翻译");
    }

    public static void main(String[] args) throws IOException{
        UdpDictServer server=new UdpDictServer(1000);
        server.start();
    }

}
